using System.Collections.Generic;

namespace Universe.OneC.DomainModel
{
    public class Map<T1, T2>
    {
        private Dictionary<T1, T2> map1;
        private Dictionary<T2, T1> map2;

        public Map()
        {
            this.map1 = new Dictionary<T1, T2>();
            this.map2 = new Dictionary<T2, T1>();
        }

        public void Add(T1 v1, T2 v2)
        {
            this.map1.Add(v1, v2);
            this.map2.Add(v2, v1);
        }

        public void Clear()
        {
            this.map1.Clear();
            this.map2.Clear();
        }

        public T1 this[T2 v2]
        {
            get
            {
                T1 local = default(T1);
                this.map2.TryGetValue(v2, out local);
                return local;
            }
        }

        public T2 this[T1 v1]
        {
            get
            {
                T2 local = default(T2);
                this.map1.TryGetValue(v1, out local);
                return local;
            }
        }
    }
}